Skip to content

[Pratt Parser] Optimize call stack depth via in-place AST mutation and lean dispatch - #2208

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_963785455
Open

[Pratt Parser] Optimize call stack depth via in-place AST mutation and lean dispatch#2208
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_963785455

Conversation

@copybara-service

Copy link
Copy Markdown

[Pratt Parser] Optimize call stack depth via in-place AST mutation and lean dispatch

  • In-place AST mutation in binary/ternary operations:
    • Updated some Parse* functions to accept ExprNode& lhs and mutate lhs in place instead of returning ExprNode by value.
    • Eliminated some intermediate named temporary rhs stack variables.
  • Lean ParseUnary and ParsePrimary dispatch:
    • Extracted prefix operator parsing (!, -) into ParseUnaryOps(), making ParseUnary() a fast single branch for standard non-prefix expressions.

…d lean dispatch

- In-place AST mutation in binary/ternary operations:
  - Updated some Parse* functions to accept ExprNode& lhs and mutate lhs in place instead of returning ExprNode by value.
  - Eliminated some intermediate named temporary rhs stack variables.
- Lean ParseUnary and ParsePrimary dispatch:
  - Extracted prefix operator parsing (!, -) into ParseUnaryOps(), making ParseUnary() a fast single branch for standard non-prefix expressions.

PiperOrigin-RevId: 963785455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant